home *** CD-ROM | disk | FTP | other *** search
- /* dcmd.h
- This is the dcmd interface.
- Copyright © 1988 Apple Computer, Inc. All rights reserved.
- */
-
- #ifndef __dcmd__
- #define __dcmd__
-
-
- // Possible requests from the debugger to the command
- #define dcmdInit 0
- #define dcmdDoIt 1
- #define dcmdHelp 2
-
-
- // Register file indices
- #define D0Register 0
- #define D1Register 1
- #define D2Register 2
- #define D3Register 3
- #define D4Register 4
- #define D5Register 5
- #define D6Register 6
- #define D7Register 7
-
- #define A0Register 8
- #define A1Register 9
- #define A2Register 10
- #define A3Register 11
- #define A4Register 12
- #define A5Register 13
- #define A6Register 14
- #define A7Register 15
-
- #define PCRegister 16
- #define SRRegister 17 // SR is only 16 bits and is stored in the high word
-
-
- // Heap block types
- #define freeBlock 0
- #define nonrelocatableBlock 1
- #define relocatableBlock 2
-
-
- typedef struct
- {
- long* registerFile;
- short request;
- Boolean aborted; // Set to true if the user types a key while scrolling
- } dcmdBlock;
-
- // EJECT
-
- // Debugger routines that can be called by the command
-
- /* Draw the text in the Pascal string as one or more lines separated by CR's.
- Each line causes the MacsBug display to be scrolled and the new line to be
- drawn at the bottom. If the user types a key while scrolling then the aborted
- flag is set telling the command to terminate immediately. */
- pascal void dcmdDrawLine(const Str255 str);
-
- /* Draw the text in the Pascal string as a continuation of the current line.
- CR's are not given special treatment. */
- pascal void dcmdDrawString(const Str255 str);
-
- /* Draw a given number of characters starting from the given pointer as a
- continuation of the current line. CR's are not given special treatment. */
- pascal void dcmdDrawText(StringPtr text, short length);
-
- /* Scrolls the MacsBug display up one line leaving a blank line at the bottom. */
- pascal void dcmdScroll();
-
- /* Display the Pascal string in the command line area and wait for a key to be pressed.
- Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
- key and adds it to the command line once the current command completes. Typing any
- key other than Return sets the aborted flag and tells the command to terminate immediately. */
- pascal Boolean dcmdDrawPrompt(const Str255 str);
-
- /* Get the current command line position */
- pascal short dcmdGetPosition();
-
- /* Set the current command line position. This should only be set to a value returned
- by dcmdGetPosition. */
- pascal void dcmdSetPosition(short pos);
-
- /* Return the next character on the command line or CR if the entire line has been scanned */
- pascal short dcmdGetNextChar();
-
- /* Return the next character on the command line or CR if the entire line has been scanned.
- However, the current command line position is not changed. */
- pascal short dcmdPeekAtNextChar();
-
- /* Copy all characters from the command line to the parameter string until a delimiter
- is found or the end of the command line is reached. A delimiter is either a space,
- a comma or a CR. Both single and double quoted strings are allowed on the command
- line. However, the leading and trailing quotes must be of the same type. The parameter
- string is returned without the quotes. This function returns the delimiter */
- pascal short dcmdGetNextParameter(Str255 str);
-
- /* Parse the command line for the next expression. All expressions are evaluated to 32 bits.
- This function returns the delimiter after the expression. The possible delimiters are
- space, comma and CR. Space is not treated as a delimiter in the middle of expressions.
- For instance, '1 + 2' will return a value of 3 and the delimiter will be the char following
- the 2. The return parameter 'ok' tells if the expression was parsed successfully. */
- pascal short dcmdGetNextExpression(long* value, Boolean* ok);
-
- /* Copy the break message MacsBug displayed the last time it was entered into str.
- This may contain multiple lines separated by CR's.*/
- pascal void dcmdGetBreakMessage(Str255 str);
-
- /* Return a symbolic representation for address in str. If no symbol can be found
- then an empty string is returned. The format of the symbol returned is Name+0000.
- With the new compilers, the name is no longer restricted to 8 characters. */
- pascal void dcmdGetNameAndOffset(long address, Str255 str);
-
- /* Return the trap name for the trap number. If no symbol can be found
- then an empty string is returned. */
- pascal void dcmdGetTrapName(short trapNumber, Str255 trapName);
-
- /* Return a pointer the macro name for the given value. If no macro can be found
- then a nil is returned. */
- pascal StringPtr dcmdGetMacroName(long value);
-
- /* When a debugger command is called, the debugger's world (low memory) is installed.
- Commands that want to reference the user's world can swap back and forth between the
- two worlds by making this call. This procedure does nothing in MacsBug. It is included
- to support other debuggers that might want to take advantage of it. */
- pascal void dcmdSwapWorlds();
-
- /* Toggle between the user and debugger displays.
- The first call restores the user's actual screen.
- The second call restores the debugger's screen. */
- pascal void dcmdSwapScreens();
-
- /* Walk thru the blocks in the current heap, calling DoThis for each block. DoThis should
- be a procedure of the form:
-
- pascal void DoThis (long blockAddress, long blockLength, long addrOfMasterPtr,
- short blockType, Boolean locked, Boolean purgeable, Boolean resource)
-
- The blockAddress and blockLength pertain to the data in the heap block, not including
- the block header. The addrOfMasterPtr is the master pointer's location in the heap,
- not the value of the master ptr. The blockType is defined by the constants freeBlock,
- nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
- reflect the state of the block. */
- typedef pascal void (*DoThisPtr) (long blockAddress, long blockLength, long addrOfMasterPtr,
- short blockType, Boolean locked, Boolean purgeable, Boolean resource);
- pascal void dcmdForAllHeapBlocks (DoThisPtr DoThis);
-
- #endif
-